
<include file="Public/header"/> 

<!-- start: Content -->
<div id="content" class="span10">
    <!--面包屑开始-->
    <ul class="breadcrumb">
        <li>
            <i class="icon-home"></i>
            <a href="index.html">Home</a> 
            <i class="icon-angle-right"></i>
        </li>
        <li><a href="#">Tables</a></li>
    </ul>
    <!--面包屑结束-->

    <!--内容区域开始-->
    <div class="row-fluid ">		
        <div class="box span12">
          <div class="box-header" data-original-title>
              <h2><i class="halflings-icon user"></i><span class="break"></span>{$Think.session.user.user_name} </h2>
                  <div class="box-icon">

                                 
                     <a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
                    </div>
                   </div>
            <div class="box-content">
                <table class="table table-striped table-bordered ">
                    <thead>
                        <tr>
                            <th>应聘人</th>
                            <th>备注内容</th>
                            <th>备注时间</th>
                            <th>备注人</th>
                        </tr>
                    </thead>   
                    <tbody>
                    <volist name="list" id="vo" >
                        <tr>
                            <td class="center user-id">{$vo.name}</td>
                            <td class="center user-name">{$vo.content}</td>
                            <td class="center user-password">{$vo.date}</td>
                            <td class="center user-password">{$vo.u_name}</td>
                            <td class="center">
                                <a class="btn btn-info edit-user" href="#">
                                    <i class="halflings-icon white edit"></i>  
                                </a>
                                <a class="btn btn-danger" href="__APP__/Home/Note/delete?id={$vo.id}" onClick="return confirm('确认要删除？');">
                                    <i class="halflings-icon white trash"></i> 
                                </a>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>            
            </div>
            <div class="pagination"> 
                {$page}
            </div>
        </div><!--/span-->

    </div><!--/row-->
    <!--添加模态窗口开始-->
    <div class="modal hide fade" id="myModal">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">×</button>
            <h3>添加用户</h3>
        </div>
        <form id="form">
            <div class="modal-body">
                <p>用户名:<input type="text" name="user_name" id="user_name">
                    <span class="user_name_span"></span>
                </p>
                <p>密  码:<input type="text" name="user_password"  id="user_password">
                <span class="user_password_span"></span></p>
            </div>
            <div class="modal-footer">
                <a href="#" class="btn" data-dismiss="modal">关闭</a>
                <a href="#" class="btn btn-primary">添加</a>
            </div>
       </form> 
    </div>
    <!--添加模态窗口结束-->



    <!--修改模态窗口开始-->
    <div class="modal hide fade" id="update-user-model">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">×</button>
            <h3>修改用户</h3>
        </div>
        <form id="user-form">
            <input type="hidden" name="user_id" id="model_user_id" >
            <div class="modal-body">
                <p>用户名:<input type="text" name="user_name" id="model_user_name"></p>
                <p>密  码:<input type="text" name="user_password" id="model_user_password"></p>
            </div>
            <div class="modal-footer">
                <a href="#" class="btn" data-dismiss="modal">关闭</a>
                <a href="#" class="btn btn-primary  update-user-submit">修改</a>
                
            </div>
        </form>     
    </div>
    <!--修改模态窗口结束-->


    <script>
        
        //修改
            $(function() {
                //打开模态窗口
                $('.edit-user').click(function(e) {
                    e.preventDefault();
                    var user_id = $(this).parent().parent().find('.user-id').html();
                    var user_name = $(this).parent().parent().find('.user-name').html();
                    var user_password = $(this).parent().parent().find('.user-password').html();
                    $('#model_user_id').val(user_id);
                    $('#model_user_name').val(user_name);
                    $('#model_user_password').val(user_password);
                    $('#update-user-model').modal('show');
                });
                
                //ajax 提交
                $('.update-user-submit').click(function() {
                    var user_id = $('#model_user_id').val();
                    var user_name = $('#model_user_name').val();
                    var user_password = $('#model_user_password').val();
                    $.ajax({
                        url: '__APP__/Home/user/save',
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            user_id: user_id,
                            user_name: user_name,
                            user_password: user_password
                        },
                        success: function(responseText) {
                            if (responseText.flag === true) {
                                 window.location.reload(); 
                                 $('#user-form').resetForm();
                            } else {
                               alert('修改失败');
                            }
                        }
                    });
                });
            });
            
            //添加
                /* $(function(){
                       //验证函数
                       function validation_user(){
                        var name = $("#user_name").val();
                        if(name.length < 2){
                            $('.user_name_span').html('用户名不能小于两位!');
                            flag = false;
                        }else{
                            $('.user_name_span').html('');
                            flag = true;
                        }
                       }
                        
                       function validation_password(){
                        var password = $("#user_password").val();
                        if(password.length < 6 ){
                            $('.user_password_span').html('密码不能小于6位!');
                            flag = false;
                        }else{
                            $('.user_password_span').html('');
                            flag = true;
                        }
                    }
                    
    
                    var flag = false;
                    $("#user_name").on('input',function(e){  
                       validation_user();
                        }); 
                       $("#user_password").on('input',function(e){  
                       validation_password(); 
                       }); 
                    
                     $('.btn-primary').click(function(){
                            if(flag){
                                var user_name = $('#user_name').val();
                                var user_password = $('#user_password').val();
                                $.ajax({
                                   url : '__APP__/Home/user/add',
                                   type : 'POST',
                                   dataType : 'json',
                                   data : {
                                       user_name : user_name,
                                       user_password : user_password   
                                   },
                                   success:  function(responseText){
                                       if (responseText.flag === true) {
                                              window.location.reload(); 
                                              $('#user-name').reset();
                                              $('#user-password').reset();
                                         } else {
                                          alert(responseText.msg);
                                         }
                                   }
                                });
                            }else{
                                 $("#user_name").on('input',function(e){  
                                    validation_user();
                                     }); 
                                    $("#user_password").on('input',function(e){  
                                    validation_password(); 
                                    }); 
                            }
  
                    });  
                    
                    

             });  */

                      
          
           
           

                          
    </script>
    <!--内容区域结束-->
    <include file="Public/footer"/>             

